#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
long long n,s,m,p;
struct sg
{
	int g,b,x;
}a[200010];
bool cmp(sg a,sg b)
{
	if(a.x!=-1&&b.x==-1)return true;
	if(a.x!=-1&&a.b<b.b)return true;
	return false;
}
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%lld",&n);
	for(int i=1; i<=n; i++)
	{
		scanf("%d",&a[i].g);
		a[i].b=i;
	}
	s=n;
	while(1)
	{
		p=0;
		for(int i=1; i<=n; i++)
		{
			if((a[i].g!=a[i-1].g&&a[i].x!=-1)||i==1)
			{
				if(p==0)printf("%d",a[i].b),p=1;
				else printf(" %d",a[i].b);
				s--;
				if(s==0)break;
			}
		}
		for(int i=1; i<=n; i++)
		{
			if((a[i].x!=-1&&a[i].g!=a[i-1].g)||i==1)a[i].x=-1;
		}
		sort(a+1,a+1+n,cmp);
		if(s==0)break;
		printf("\r");
	}
	return 0;
}
